<template>
	<!-- 确定订单 v-if="cart.length !== 0"-->
	<view class="cart-container">
		<view class="addressIcon-box" v-if="addressResult.length===0">
			<view class="addressIcon-box-to" >
				<uni-icons type="location-filled" size="30" color="#ff5555"></uni-icons>
				<view>请先填写地址，再确认订单信息</view>
			</view>
			<navigator class="addressIcon-navigator" url="/subpkg/addressList/addressList">现在去填写>></navigator>
		</view>
		<view v-else class="addressIcon-container">
		<!-- 	<view v-if="formData.recipientName">
				<view class="addressIcon-top">
					<view class="addressIcon-box-to">
						<uni-icons type="location-filled" size="30" color="#ff5555"></uni-icons>
						<view>{{formData.recipientName}}</view>
					</view>
					<view style="margin : 10rpx;">{{formData.recipientPhone}}</view>
				</view>
				<view style="background-color: white;padding: 0rpx 0rpx 10rpx 10rpx;color:#8e8b8b;">
					{{formData.recipientAddress}}
				</view>
			</view> -->
		<!-- 	<view v-else> -->
				<view class="addressIcon-top" @click="toAddressList">
					<view class="addressIcon-box-to">
						<uni-icons type="location-filled" size="30" color="#ff5555"></uni-icons>
						<view>{{addressTitle.name}}</view>
					</view>
					<view style="margin : 10rpx;">{{addressTitle.phone}}</view>
				</view>
				<view style="background-color: white;padding: 0rpx 0rpx 10rpx 10rpx;color:#8e8b8b;">
					{{addressTitle.province}}{{addressTitle.city}}{{addressTitle.region}} {{addressTitle.streetAddress}}
				</view>
			</view>
		<!-- </view> -->

	</view>
	<!-- 没有订单 -->
</template>

<script>
	import request from '../../utils/request.js';
	import {
		mapState,
		mapGetters,
		mapMutations
	} from 'vuex'

	export default {
		name: "myaddress",
		computed: {
			// ...mapGetters('m_order', ['orderInfo']),
			addressTitle() {
				const data = this.addressResult.filter(item => item.status === 1);
				// console.log(data[0], '000')
				return data[0]
			},

		},
		created() {
			// this.formData = this.orderInfo;
			// this.getAddress()
			this.refreshData()
		},
		data() {
			return {
				formData: {
					size: 10,
					current: 1
				},
				// total: '',
				 orderData: {
					token: '',
					addressId: '',
					shopId: '',
					message: "",
					payType: '',
					exchangeCount: ''
				},
				addressResult: [],
				addressShow: []
			};
		},
		methods: {
			refreshData() {
			    this.getAddress(); // 重新获取地址数据;
			  },
			// 到地址列表
			toAddressList() {
				uni.navigateTo({
					url: '/subpkg/addressList/addressList'
				})
			},
			exchangeAddress(){
				this.$emit('exchangeAddress',this.addressTitle)
			},
			// 获取到地址
			getAddress() {
				request.get('/memberAddress/getList', this.formData).then(res => {
					if (res.code === 0) {
							this.addressResult =  res.data  ;
							this.exchangeAddress();
					} else {
						uni.$showMsg(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.cart-container {
		font-size: 30rpx;

		// padding :10rpx 10rpx 50rpx 10rpx;
		.addressIcon-box {
			margin-top: 5rpx;
			background-color: white;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.addressIcon-box-to {
				font-weight: bold;
				display: flex;
				align-items: center;
			}

			.addressIcon-navigator {
				margin-right: 10rpx;
				color: #ff5555;
			}
		}

		.addressIcon-container {
			margin-top: 5rpx;
			background-color: white;

			.addressIcon-top {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.addressIcon-box-to {
					font-weight: bold;
					display: flex;
					align-items: center;
				}
			}

		}
	}

	.cart-title {
		height: 40px;
		display: flex;
		align-items: center;
		padding-left: 5px;
		border-bottom: 1px solid #EFEFEF;

		.cart-title-text {
			font-size: 14px;
			margin-left: 10px;
		}
	}

	.empty-cart {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 150px;

		.empty-img {
			width: 90px;
			height: 90px;
		}

		.tip-text {
			font-size: 12px;
			color: gray;
			margin-top: 15px;
		}
	}

	.goods_button {
		position: fixed;
		bottom: 0;
		// left: 0;
		right: 0;

		.goods_buttonBox {
			display: flex;
			justify-content: flex-end;

			.button_left {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.goodsInfo_goodsInfo1 {
					height: 60rpx;
					padding: 0 40rpx;
					line-height: 60rpx;
					text-align: center;
					background-color: orange;
				}
			}

			.goodsInfo-goodsInfo {
				display: flex;
				color: white;

				.goodsInfo_goodsInfo0 {
					height: 60rpx;
					padding: 0 30rpx;
					text-align: center;
					line-height: 60rpx;
					background-color: #f4f438;
				}

				// .goodsInfo_goodsInfo1 {
				// 	height: 60rpx;
				// 	padding: 0 40rpx;
				// 	line-height: 60rpx;
				// 	text-align: center;
				// 	background-color: orange;
				// }
			}

			.uni-goods-nav {
				width: 150px;
			}
		}


	}

	.product_list_box {
		padding-top: 10rpx;


		.product_list_title {
			font-size: 24rpx;
			font-weight: 400;
			color: #706e6e;
			padding-left: 15rpx;
			line-height: 60px;
			background-color: white;
			border-bottom: 1px solid #EFEFEF;
		}

		.product_express {
			padding-left: 15rpx;
			// margin: 0 15rpx;
			background-color: white;
			display: flex;
			line-height: 40px;
			border-bottom: 1px solid #EFEFEF;
		}

		.product_list_item {
			background-color: white;
			padding: 30rpx 10px 30px 10px;
			// line-height: 60px;
			border-bottom: 1px solid #EFEFEF;

			.product_item_left {
				display: flex;

				.produce_image {
					height: 200rpx;
					width: 300rpx;
					// width: 40%;
					// display: block !important;
				}

				.produce_details {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					margin: 10px;

					.produce_name {}

					.produce_price {
						display: flex;
						justify-content: space-between;

						.price_box {
							color: orangered;
						}
					}
				}
			}
		}
	}

	.message_box {
		background-color: white;
		display: flex;
		padding: 10px;
		border-bottom: 1px solid #EFEFEF;

		.uni-easyinput {
			.is-input-border {
				border: none !important;
			}

		}

		// padding: 10px;
	}
</style>